const { defineConfig } = require('@vue/cli-service')
const path = require('path')
// console.log(1111111)
// console.log(process.env.NODE_ENV)
// console.log(process.env.VUE_APP_BASE_URL)
function resolve (dir) {
  return path.join(__dirname, dir)
}
module.exports = defineConfig({
  transpileDependencies: true,
  devServer: {

    host: 'localhost',
    // 自动打开浏览器
    open: false,
    // 端口
    port: 8080,
    proxy: {
      '/api': {
        target: 'https://heimahr.itheima.net'
      }
    }
  },
  chainWebpack (config) {
    // set svg-sprite-loader
    config.module
      .rule('svg')
      // eslint-disable-next-line no-undef
      .exclude.add(resolve('src/icons'))
      .end()
    config.module
      .rule('icons')
      .test(/\.svg$/)
      // eslint-disable-next-line no-undef
      .include.add(resolve('src/icons'))
      .end()
      .use('svg-sprite-loader')
      .loader('svg-sprite-loader')
      .options({
        symbolId: 'icon-[name]'
      })
      .end()
  }
})
